

# common constant
GAME_PORT = 50007

HEART_BEAT_TIME = 1

# Protocol: HEAD_NUMBER_SIZE digit hex for message size followed by the message itself
# fmtX = '%%%sX' %('0'+str(HEAD_NUMBER_SIZE))
# to send msg: send(fmtX %len(msg) + msg)
# to recv msg: buf += recv(conn) until len(buf[HEAD_NUMBER_SIZE:]) == int(buf[:HEAD_NUMBER_SIZE],16)
HEAD_NUMBER_SIZE = 8
fmtX = '%%%sX' %('0'+str(HEAD_NUMBER_SIZE))

TERMINATOR = '\x09\x09\x09'

MSG_HEAD = 4 # = len('INFO')
cmd_table = {'info':'INFO', 'cmd':'CMD0', 'heart':'HHHH','conf':'CONF', 'seat':'SEAT'}

# configuration
NAME_FIELD = 'name'
NICKNAME_FIELD = 'nickname'
TABLE_SEAT_FIELD = 'seat'
conf_tab = {NAME_FIELD:'Bob.Smith', NICKNAME_FIELD:'goody', TABLE_SEAT_FIELD:'EAST'}

# server
CLIENT_WAIT_FOR_SERVER = 1
TOTAL_CLIENTS = 4
SERVER_CLIENT_PROC_SLEEP = 0.1
SERVER_CLIENT_SLEEP_TIME = 0.1
server_main_state = {'OK':1, 'stop':2, 'err':-1}
TABLE_SEAT = ['East', 'South', 'West', 'North']

# client
CLIENT_GUI_TXT_POLL_TIME_MS = 100
CLIENT_OFF_CHECK_SLEEP_TIME = 1
ClientStt = {'trying':1, 'connected':2, 'lost':3, 'exit':4, 'fail':5}                

#others
MAGIC_WORD = 'ugosnutoo'